import React from 'react';
import { Menu, Icon } from 'antd';
import { Router, Route, Link } from 'react-router';
import NavLink from './navLink'
const SubMenu = Menu.SubMenu;

const LeftMenu = React.createClass({

  contextTypes: {
    router: React.PropTypes.object
  },

  getInitialState() {

    return {
      selectedKey: ['workSpace'],
      defaultOpenKey: ['landlord']
    }
  },

  handleClick(e) {
    this.setState({
      selectedKey: e.keyPath,
    });
  },

  render () {

    let pathHash = location.hash;
    let pathStr = pathHash.substring(2, pathHash.lastIndexOf('?'));
    let pathArr = pathStr.split('/');
    let selected = pathArr[1] ? pathArr : this.state.selectedKey;
    let opened = pathArr[1] ? pathArr : this.state.defaultOpenKey;
    return (
      <Menu mode="inline" theme="dark"
            onClick={this.handleClick}
            defaultOpenKeys={opened}
            selectedKeys={selected}>
        
        <Menu.Item key="workSpace"><NavLink to="/workSpace" ><span><Icon type="laptop" />工作台</span></NavLink></Menu.Item>

        <SubMenu key="landlord" title={<span><Icon type="user" />我是房东</span>}>
          <Menu.Item key="bulkImport"><NavLink to="/landlord/bulkImport">批量导入</NavLink></Menu.Item>
          <Menu.Item key="rentBeforeIndex"><NavLink to="/landlord/rentBeforeIndex">意向房源</NavLink></Menu.Item>
          <Menu.Item key="houseResource"><NavLink to="/landlord/houseResource">房源管理</NavLink></Menu.Item>
          <Menu.Item key="houseDecoration"><NavLink to="/landlord/houseDecoration">房屋装修</NavLink></Menu.Item>
          <SubMenu key="rentManage" title="出租管理">
            <Menu.Item key="rentRooms"><NavLink to="/landlord/rentManage/rentRooms">房间出租</NavLink></Menu.Item>
            <Menu.Item key="reservationOrderList"><NavLink to="landlord/rentManage/reservationOrderList">预约单</NavLink></Menu.Item>
            <Menu.Item key="advanceOrder"><NavLink to="/landlord/rentManage/advanceOrder">预订单</NavLink></Menu.Item>
            <Menu.Item key="signUpOrder"><NavLink to="/landlord/rentManage/signUpOrder">签约单</NavLink></Menu.Item>
            <Menu.Item key="checkOutList"><NavLink to="/landlord/rentManage/checkOutList">退房列表</NavLink></Menu.Item>
          </SubMenu>
          <Menu.Item key="batchCharging"><NavLink to="/landlord/batchCharging">批量抄表</NavLink></Menu.Item>
        </SubMenu>

        <SubMenu key="count" title={<span><Icon type="bar-chart" />统计中心</span>}>
            <Menu.Item key="tenantCountIndex"><NavLink to="/count/tenantCountIndex">租客统计</NavLink></Menu.Item>
            <Menu.Item key="ownerCountIndex"><NavLink to="/count/ownerCountIndex">业主统计</NavLink></Menu.Item>
            <Menu.Item key="roomCountIndex"><NavLink to="/count/roomCountIndex">房间统计</NavLink></Menu.Item>
            <Menu.Item key="rentRecordIndex"><NavLink to="/count/rentRecordIndex">收租记录</NavLink></Menu.Item>
        </SubMenu>

        <SubMenu key="finance" title={<span><Icon type="pay-circle-o" />财务管理</span>}>
            <Menu.Item key="capitalIndex"><NavLink to="/finance/capitalIndex">资金汇总</NavLink></Menu.Item>
            <Menu.Item key="rentBillIndex"><NavLink to="/finance/rentBillIndex">租客账单</NavLink></Menu.Item>
            <Menu.Item key="payBillIndex"><NavLink to="/finance/payBillIndex">支出账单</NavLink></Menu.Item>
        </SubMenu>

        <SubMenu key="financial" title={<span><Icon type="share-alt" />金融支持</span>}>
          <Menu.Item key="loanIndex"><NavLink to="/financial/loanIndex">贷款申请</NavLink></Menu.Item>
        </SubMenu>
        <SubMenu key="system" title={<span><Icon type="setting" />账户设置</span>}>
          <Menu.Item key="securityIndex"><NavLink to="/system/securityIndex">账户安全</NavLink></Menu.Item>
          <Menu.Item key="InfoIndex"><NavLink to="/system/InfoIndex">账户资料</NavLink></Menu.Item>
          <Menu.Item key="rechargeIndex"><NavLink to="/system/rechargeIndex">账户充值</NavLink></Menu.Item>
          <Menu.Item key="cashIndex"><NavLink to="/system/cashIndex">账户提现</NavLink></Menu.Item>
           <Menu.Item key="myCountIndex"><NavLink to="/system/myCountIndex">我的账户</NavLink></Menu.Item>
          <Menu.Item key="recordIndex"><NavLink to="/system/recordIndex">资金记录</NavLink></Menu.Item>
        </SubMenu>
      </Menu>
    );
  }
});

export default LeftMenu

